<!-- page heading start-->
<div class="page-heading">
    <h3>
        	菜单管理 <small></small>
    </h3>
    <ul class="breadcrumb">
        <li>
            <a href="#menu_list">用户授权</a>
        </li>
        <li class="active">菜单管理 </li>
    </ul>
</div>
<!-- page heading end-->
<div class="col-lg-4">
	<section class="panel" style="height:600px; overflow:auto;">
		<header class="panel-heading">菜单树
			<span class="tools pull-right">
				<!-- <a  class="fa fa-chevron-down"></a> 
				<a  class="fa fa-times"></a> -->
			</span>
		</header>
		<div class="panel-body">
			<div class="m-bot15">
				<div class="from-group">
					<button class="btn btn-primary" ng-click="addMain()"> 添加 </button>
				</div>
			</div>
			<div class="tree">
			    <ul>
			        <li ng-repeat="menu in menuList" menu-tree>
			            <span ng-bind="menu.m_name"><i class="icon-folder-open"></i> </span> 
			            <a href="javascript:void(0);" ng-click="add(menu.id)" style="display: none; overflow: hidden;"> 添加</a> 
			            <a href="javascript:void(0);" ng-click="edit(menu.id)" style="display: none; overflow: hidden;"> 修改</a> 
			            <a href="javascript:void(0);" ng-click="del(menu.id)" style="display: none; overflow: hidden;"> 删除</a>
			            <ul>
			                <li ng-repeat="child in menu.childrenList" style="overflow: hidden; display: none;">
			                	<span ng-bind="child.m_name"><i class="icon-minus-sign"></i> </span> 
			                	<a href="javascript:void(0);" ng-click="edit(child.id)"> 修改</a> 
			                	<a href="javascript:void(0);" ng-click="del(child.id)"> 删除</a>
			                </li>
			            </ul>
			        </li>
			    </ul>
			</div>
		</div>
	</section>
</div>
<div class="col-lg-8 hide" id="info">
	<section class="panel" style="height:600px;">
           <header class="panel-heading" style="height:10%"> 
	       	    <span ng-if="isEdit" > 编辑菜单 </span>
	           	<span ng-if="isAdd" > 添加子菜单 </span>
	           	<span ng-if="isMain" > 添加一级菜单 </span>
       	    <div style="float:right;margin-top:-0.5%;">
				<button class="btn btn-danger" style="font-size: 12px;" ng-disabled="menuForm.$invalid || perForm.$invalid"
				ng-click="addOrEdit ? update():save()">保存</button>
				<button type="reset" style="font-size: 12px;" class="btn btn-default" ng-click="back()">返回</button>
           </div>
           </header>
           
           <div class="panel-body" >
               <form class="form-horizontal" role="form" name="menuForm">
				<input type="text" ng-hide="true" ng-model="menu.id" name="id">
                  <div class="form-group" ng-class="{'has-error':menuForm.m_name.$dirty && menuForm.m_name.$invalid}" style="margin-top:26px;">
                       <label for="m_name" class="col-lg-2 col-sm-2 control-label">菜单名称</label>
                       <div class="col-lg-4">
                           <input type="text" class="form-control" id="inputTypeName" ng-model="menu.m_name" placeholder="请输入菜单名称"
							name="m_name" ng-required="true" ng-minlength="2" ng-maxlength="20">
                           <div for="m_name" 
                           ng-show="menuForm.m_name.$dirty && menuForm.m_name.$error.minlength" class="alert alert-danger help-block">* 长度不能小于2位</div>
                           <div for="m_name"  
                           ng-show="menuForm.m_name.$dirty && menuForm.m_name.$error.maxlength" class="alert alert-danger help-block">* 长度不能超过10位</div>
                       </div>
                   </div>
                   
                   <div class="form-group" ng-class="{'has-error':myForm.m_url.$dirty && myForm.m_url.$invalid}"style="margin-top:26px;">
                       <label for="inputTypeName" class="col-lg-2 col-sm-2 control-label">菜单路径</label>
                       <div class="col-lg-4">
                           <input type="text" class="form-control" id="inputTypeName" ng-model="menu.m_url" placeholder="菜单路径必须以‘#’开始"
							name="m_url" ng-required="true" ng-minlength="1" ng-maxlength="30" ng-pattern="/^#/">
                            <label for="inputTypeName"  
                           ng-show="menuForm.m_url.$dirty && menuForm.m_url.$error.minlength" class="alert alert-danger help-block">* 长度不能小于1位</label>
                           <label for="inputTypeName"  
                           ng-show="menuForm.m_url.$dirty && menuForm.m_url.$error.maxlength" class="alert alert-danger help-block">* 长度不能超过30位</label>
		                <label for="inputTypeName" 
		                ng-show="menuForm.m_url.$dirty && menuForm.m_url.$error.pattern" class="alert alert-danger help-block"> 菜单路径必须以‘#’开始</label>
                       </div>
                   </div>
                   
                   <div class="form-group" ng-class="{'has-error':myForm.m_descriptionl.$dirty && myForm.m_descriptionl.$invalid}"style="margin-top:26px;">
                       <label for="inputTypeName" class="col-lg-2 col-sm-2 control-label">菜单描述</label>
                       <div class="col-lg-4">
                           <input type="text" class="form-control" id="inputTypeName" ng-model="menu.m_description" placeholder="请输入菜单描述"
							name="m_description" ng-required="true" ng-minlength="2" ng-maxlength="20">
                           <label for="inputTypeName"  
                           ng-show="menuForm.m_description.$dirty && menuForm.m_description.$error.minlength" class="alert alert-danger help-block">* 长度不能小于2位</label>
                           <label for="inputTypeName"  
                           ng-show="menuForm.m_description.$dirty && menuForm.m_description.$error.maxlength" class="alert alert-danger help-block">* 长度不能超过20位</label>
                       </div>
                   </div>
      			
        		<div class="form-group"style="margin-top:26px;" >
         			<label for="inputTypeName" class="col-lg-2 col-sm-2 control-label">图标样式</label>
		            <div class="col-lg-4">
		                <input type="button" ng-click="clickButtonIcon()" class="btn btn-default" value="选择图标">
		                <input type="text" ng-hide="true" ng-model="menu.m_icon" value="{{menu.m_icon}}">
		                <i ng-class="menu.m_icon"></i>
		            </div>
       			</div>
				
				<div class="form-group"style="margin-top:26px;">
					<label class="col-lg-2 col-sm-2 control-label">是否显示</label>
                       <div class="col-lg-6">
						<label class="radio-inline" ng-init="m_is_show = 1"> 
							<input type="radio"  ng-model="menu.m_is_show" name="m_is_show" ng-checked="true" ng-value="1" />是
						</label> 
						<label class="radio-inline"> 
							<input type="radio"  ng-model="menu.m_is_show" name="m_is_show" value="0" />否
						</label>
					</div>
				</div>
				
				<div class="form-group"style="margin-top:26px;">
					<label class="col-lg-2 col-sm-2 control-label">是否在新窗口打开</label>
                       <div class="col-lg-6">
						<label class="radio-inline" ng-init="m_is_show = 1"> 
							<input type="radio" ng-model="menu.m_is_new_open" name="m_is_new_open" ng-checked="true" ng-value="1" />是
						</label> 
						<label class="radio-inline"> 
							<input type="radio" ng-model="menu.m_is_new_open" name="m_is_new_open" value="0" />否
						</label>
					</div>
				</div>
                   
                   <div class="form-group"  ng-class="{'has-error':myForm.m_sort.$dirty && myForm.m_sort.$invalid}"style="margin-top:26px;">
                       <label for="inputTypeValue" class="col-lg-2 col-sm-2 control-label">排序</label>
                       <div class="col-lg-4">
                          	<input type="text" ng-pattern="/^[1-9]\d*/" autocomplete="off" placeholder="排序"
							ng-required="true" ng-maxlength="8" id="doc-ipt-4"
							ng-model="menu.m_sort" name="m_sort" class="form-control">
						<div ng-show="menuForm.m_sort.$dirty && menuForm.m_sort.$error.maxlength"
							class="alert alert-danger help-block" class="alert alert-danger help-block">长度不能超过8位</div>
						<div ng-show="menuForm.m_sort.$dirty && menuForm.m_sort.$error.pattern"
							class="alert alert-danger help-block" class="alert alert-danger help-block">必须为数字,且不能以0开头</div>
                       </div>
                   </div>
                   <div class="form-group" ng-show = "showPermission" style="margin-top:26px;">
                   	<label for="inputTypeValue" class="col-lg-2 col-sm-2 control-label">菜单对应权限</label>
           	        <div class="col-lg-6">
                           <input type="button" style="background-color: white;color:green;"  placeholder="" value="+" ng-click="addPermisson(menu.id)">
                       </div>
		        </div>
               </form>
           </div>
       </section>
    <form class="form-horizontal" name="perForm"  style="height:500px; overflow:scroll;">
       <div class="col-lg-4" ng-repeat="i in permissionList"  ng-show = "showPermission" >
       <section class="panel">
           <header class="panel-heading"> 
          		<span>权限</span>
           </header>
           <div class="panel-body" >
                   	<input class="form-control" type="hidden" ng-model = "$parent.permissionList[$index].id">
                    <div class="form-group">
			        		<label class="col-sm-3 control-label">名称</label>
			        		<div class="col-sm-8">
	                     		<input class="form-control" type="text" ng-model="$parent.permissionList[$index].p_name"
									name="p_name{{$index}}" ng-required="true" ng-maxlength="30" ng-minlength="2">
								<div ng-show="perForm.p_name{{$index}}.$dirty && perForm.p_name{{$index}}.$error.minlength" class="alert alert-danger help-block">
								* 长度不能少于2位
								</div>
								<div ng-show="perForm.p_name{{$index}}.$dirty && perForm.p_name{{$index}}.$error.maxlength" class="alert alert-danger help-block">
								* 长度不能超过30位
								</div>
			        		</div>
			        </div>
			        <div class="form-group">
			        		<label class="col-sm-3 control-label">标识</label>
			        		<div class="col-sm-8">
			        			<input class="form-control" type="text" ng-model="$parent.permissionList[$index].p_value"
									name="p_value{{$index}}" ng-required="true" ng-maxlength="60" ng-minlength="2">
								<div  ng-show="perForm.p_value{{$index}}.$dirty && perForm.p_value{{$index}}.$error.minlength" class="alert alert-danger help-block">
								* 长度不能少于2位
								</div>
								<div ng-show="perForm.p_value{{$index}}.$dirty && perForm.p_value{{$index}}.$error.maxlength" class="alert alert-danger help-block">
								* 长度不能超过60位
								</div>			        		
			        		</div>
			        </div>
			        <div class="form-group">
			        		<label class="col-sm-3 control-label">路径</label>
			        		<div class="col-sm-8">
			        			<input class="form-control" type="text" ng-model="$parent.permissionList[$index].p_path"
									name="p_path{{$index}}" ng-required="true" ng-maxlength="60" ng-minlength="2">
								<div ng-show="perForm.p_path{{$index}}.$dirty && perForm.p_path{{$index}}.$error.minlength" class="alert alert-danger help-block">
								* 长度不能少于2位
								</div>
								<div ng-show="perForm.p_path{{$index}}.$dirty && perForm.p_path{{$index}}.$error.maxlength" class="alert alert-danger help-block">
								* 长度不能超过60位
								</div>
			        		</div>
			        </div>
					<div class="form-group">
			        		<label class="col-sm-3 control-label">排序</label>
			        		<div class="col-sm-8">
	                     		<input type="text" class="form-control" ng-pattern="/^[1-9]\d*/" autocomplete="off"
									ng-required="true" ng-maxlength="5" id="doc-ipt-4"
									ng-model="$parent.permissionList[$index].p_sort" name="p_sort{{$index}}">
								<div ng-show="perForm.p_sort{{$index}}.$dirty && perForm.p_sort{{$index}}.$error.maxlength" class="alert alert-danger help-block">
								* 长度不能超过5位
								</div>
								<div ng-show="perForm.p_sort{{$index}}.$dirty && perForm.p_sort{{$index}}.$error.pattern"  class="alert alert-danger help-block">
								* 必须为数字,且不能以0开头
								</div>
			        		</div>
			        </div>
			        <div class="form-group">
			        		<label class="col-sm-3 control-label">说明</label>
			        		<div class="col-sm-8">
			        			<input type="text" class="form-control" ng-model="$parent.permissionList[$index].p_description"
									name="p_description{{$index}}" ng-maxlength="60">
								<div ng-show="perForm.p_description{{$index}}.$dirty && perForm.p_description{{$index}}.$error.maxlength" class="alert alert-danger help-block">
								* 长度不能超过60位
								</div>
			        		</div>
	        		</div>
	        		<div class="form-group">
			        		<label class="col-sm-3 control-label"></label>
			        		<div class="col-sm-8">
			        			<input type="button" ng-click="delPermisson($index)" value="X" class = "X" >
			        		</div>
			        </div>
			</div>
	</section>
	</div>
  </form>
</div>
<!--body wrapper end-->
<div class="modal fade" id="inons" tabindex="-1" role="dialog" 
		data-backdrop="static" aria-labelledby="modalConfirmLabel" aria-hidden="true">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal"
					aria-hidden="true">X</button>
				<h4 class="modal-title" id="modalConfirmLabel" ng-click="modalConfirmLabel()">
					选择图标
				</h4>
			</div>
			<div class="modal-body" style="height: 300px;overflow-y: scroll;">
				<div common-icon>
	                 <div class="col-md-1" ng-repeat="icon in iconList">
	                 	<a href="javascript:;" class="imgIcon" ng-click="imgIcon(icon.VALUE)" data-value="{{icon.value}}">
		                 	<i class="{{icon.VALUE}}"></i>
	                 	</a>
	                 </div>
				</div>
                 <div style="clear:both;"></div>
			</div>
		</div>
	</div>
</div>